package com.xsomnus.spring_framework.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xsomnus.spring_framework.entity.User;
import com.xsomnus.spring_framework.mapper.UserMapper;
import com.xsomnus.spring_framework.service.IUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.aop.framework.AopContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author @xsomnus666_xiawenye★
 * @since 2019/7/26 0026 12:09
 * - 才需学也,学需静也/非淡泊无以明志，非宁静无以致远
 */
@Slf4j
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {



    @Override
    @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
    public void addUser(String name) {
        log.info("addUser begin ....");
        save(new User().setId(name).setLeftFee(99).setVersion(0));
        log.info("addUser end .");
    }
}
